package fiuba.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.TreeSet;
import java.util.HashSet;
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.lang.StringBuffer;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;

@Entity
public class Contenedor extends BaseObject implements Comparable<Contenedor> {
	private Long id;
	private String Nombre;
	private List <ItemContenedor> items  = new ArrayList<ItemContenedor>();;

	/**
	 * 
	 */
	private static final long serialVersionUID = -3356460793743588520L;

	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
	@Id @GeneratedValue(strategy = GenerationType.AUTO) 
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@Column(length=30, unique=true)
	public String getNombre() {
		return Nombre;
	}

	public void setNombre(String nombre) {
		Nombre = nombre;
	}

	@OneToMany(mappedBy="contenedor")
//	@Sort(type = SortType.COMPARATOR, comparator = ItemContenedorComparator.class)
	public List<ItemContenedor> getItems() {
		Collections.sort(this.items);
		return items;
	}

	public void setItems(List<ItemContenedor> items) {
		this.items = items;
	}

	public int compareTo(Contenedor arg0) {
		return this.getNombre().compareToIgnoreCase(arg0.getNombre());
	}

}
